<?php


function list_penilaian(){
	$header = array(
		'#'=>array('style'=>'border-bottom:2px solid;width:5%'),  
		'Periode'=>array('style'=>'border-bottom:2px solid;width:85%'),  
		' '=>array('style'=>'border-bottom:2px solid;width:10%'), 
	);

	$query = "SELECT * FROM penilaian ORDER BY tanggal DESC ";
	$result = my_query($query);
	$i = 0;
	$row=array();
	while($ey = my_fetch_array($result)){
		$i++;

		$detailproperty = array(
			'href'=>'index.php?com=penilaian&task=list_karyawan&penilaian_id='.$ey['penilaian_id'],
			'title'=>'Karyawan'
		);
		$detail_button = button_icon( 'b_props.png' , $detailproperty  );
 
		$row[] = array(
			'#'=>position_text_align ($i, 'center'), 
			'periode'	=> position_text_align ( date("m-Y", strtotime($ey['tanggal'] ." 00:00:00" ) ), 'left'), 
			'operasi'=> position_text_align( $detail_button, 'right'),  
		);
		 
	}
	$datas = table_rows($row);  
 
	return table_builder($header , $datas ,  3 , false );
} 

function list_karyawan($penilaian_id){
	$header = array(
		'#'=>array('style'=>'text-align:center;border-bottom:2px solid;width:5%'), 
		'nik'=>array('style'=>'text-align:center;border-bottom:2px solid;width:10%'),   
		'nama'=>array('style'=>'border-bottom:2px solid;width:30%'),  
		'jabatan'=>array('style'=>'border-bottom:2px solid;width:35%'), 
		'nilai'=>array('style'=>'border-bottom:2px solid;width:10%'), 		
		' '=>array('style'=>'border-bottom:2px solid;width:10%'), 
	);
	
	$query = "
		SELECT a.karyawan_id, c.evaluasi_nilai_id FROM karyawan a 
		INNER JOIN biodata b ON a.biodata_id = b.biodata_id
		LEFT JOIN penilaian_karyawan c ON c.karyawan_id = a.karyawan_id AND c.penilaian_id={$penilaian_id} 
		WHERE a.karyawan_id NOT IN (select karyawan_id FROM karyawan_disable)
		AND a.karyawan_id NOT IN (select karyawan_id FROM pemberhentian)" ;
		
	$nik_start = isset( $_GET['nik_start'] ) ? sprintf('%07d',(int) $_GET['nik_start']) :  '0000001';
	$nik_end = isset( $_GET['nik_end'] ) ? sprintf('%07d',(int) $_GET['nik_end']) :  '9999999' ;		
	if( isset($_GET['nik_start']) OR isset($_GET['nik_end']) ){		
		$query .=" AND (a.nik BETWEEN {$nik_start} AND {$nik_end} ) " ;
	}	
	$query .=" ORDER BY a.nik";
	$result = my_query($query );
	$total_records = my_num_rows($result );
	$scroll_page =5;  
	$per_page =15;  
	$current_page = isset($_GET['page']) ? (int) $_GET['page'] : 1 ; 
	if($current_page < 1){
		$current_page = 1;
	}
	$pager_url  ="index.php?com={$_GET['com']}&task={$_GET['task']}&penilaian_id={$penilaian_id}&nik_start{$nik_start}&nik_end{$nik_end}&page=";		
	//$pager_url  ="index.php?com={$_GET['com']}&task={$_GET['task']}&penilaian_id={$_GET['penilaian_id']}&key={$_GET['key']}&page=";	 
	$inactive_page_tag = 'style="padding:4px;background-color:#BBBBBB"';  
	$previous_page_text = ' Mundur '; 
	$next_page_text = ' Maju ';  
	$first_page_text = ' Awal '; 
	$last_page_text = ' Akhir ';
	
	$kgPagerOBJ = new kgPager();
	$kgPagerOBJ->pager_set(
		$pager_url, 
		$total_records, 
		$scroll_page, 
		$per_page, 
		$current_page, 
		$inactive_page_tag, 
		$previous_page_text, 
		$next_page_text, 
		$first_page_text, 
		$last_page_text ,$pager_url_last); 
	 		
	$result = my_query($query ." LIMIT ".$kgPagerOBJ->start.", ".$kgPagerOBJ->per_page); 	
	$row = array(); 
	$i = ($current_page  - 1 ) * 15; 
	while($ey = my_fetch_array($result )){
		$i++;
		$karyawan = loaddata_karyawan($ey['karyawan_id']);  
		$jabatans = my_get_data_by_id('jabatan','jabatan_id',( isset($karyawan['jabatan_id']) ? $karyawan['jabatan_id'] : 0 ));
		
		$detailproperty = array(
			'href'=>'index.php?com=penilaian&task=list_evaluasi&penilaian_id='.$penilaian_id.'&karyawan_id='.$ey['karyawan_id'],
			'title'=>'Evaluasi'
		);
		$detail_button = button_icon( 'b_props.png' , $detailproperty  );
	
		$evaluasi_nilai_id=(isset($ey['evaluasi_nilai_id']) ? $ey['evaluasi_nilai_id'] :0 );
		$evaluasi_nilais = my_get_data_by_id('evaluasi_nilai','evaluasi_nilai_id',$evaluasi_nilai_id );
		$row[] = array(
			'#'=>position_text_align ($i, 'center'),
			'nik'=>position_text_align( $karyawan['nik'], 'center'),
			'nama'=>$karyawan['nama_gelar'],  
			'jabatan'=> $jabatans['nama_jabatan'],  
			'nipar'=>$evaluasi_nilais['keterangan'],  
			'operasi'=> position_text_align( $detail_button .' '.$edit_button, 'right'),  
		);
	}
	
	$datas = table_rows($row); 
	$menuontop = array(  
		'Cetak' => array('onclick'=>'javascript:window.open(\'index.php?com='.$_GET['com'].'&task=plaincetak&penilaian_id='.$penilaian_id.'&nik_start='.$nik_start.'&nik_end='.$nik_end.'\',\'mywin\',\'left=20,top=20,width=800,height=600,toolbar=0,resizable=0\');'),
		'Upload Skor'=>array('onclick'=>'javascript:jQuery.facebox({ ajax: \'index.php?com='.$_GET['com'].'&task=upload_skor&penilaian_id='.$penilaian_id.'\' })'),
		'Excel'=>array('onclick'=>'javascript:location.href=\'index.php?com='.$_GET['com'].'&task=excel&penilaian_id='.$penilaian_id.'&nik_start='.$nik_start.'&nik_end='.$nik_end.'\';'),
		'Kembali'=>array('onclick'=>'javascript:location.href=\'index.php?com='.$_GET['com'].'\';'),
	);	
	$paging = $kgPagerOBJ ->showPaging();
	$search = '<form method="GET">
	<input type="hidden" name="com" value="'.$_GET['com'].'" />
	<input type="hidden" name="task" value="'.$_GET['task'].'" />
	<input type="hidden" name="penilaian_id" value="'.$_GET['penilaian_id'].'" />
	<span style="font:10px verdana"><b>NIK Range</b></span><br/>
	<input type="text"  size="7" name="nik_start" value="'.$nik_start.'" />
	<span style="font:10px verdana">s/d</span>
	<input type="text"  size="7" name="nik_end" value="'.$nik_end.'" />
	<input class="simple_search" type="submit" value=" CARI " /> </form>';
	$penilaians = my_get_data_by_id('penilaian','penilaian_id',$penilaian_id );
	$view ='<table width="98%" cellspacing="0" cellpadding="4"><tr>'; 
	$view .= '<table width="100%"   style="border-collapse:collapse;border-color:white" cellspacing="0" cellpadding="2">';
	$view .= form_field_display( '<span class="label_form">'.  date( "m-Y" , strtotime($penilaians['tanggal'])) .'</span>'   , "<b>Periode</b>"    ); 
	$view .= '</table>';
	$view .= '</td></tr></table><br/>';

	$printmenu = additional_menu_on_list( $menuontop , $search  );
	$paging = $kgPagerOBJ ->showPaging();
	return  $view.$printmenu .table_builder($header , $datas ,  5 , false,$paging );
}


function upload_form_page(){
	$view = form_header( "upload" , "upload"  );
	/*
	
	$last_struktur = "SELECT * FROM pr_struktur_gaji_tahun ORDER BY struktur_gaji_id limit 1 ";
	$last_struktur_result = my_query($last_struktur);
	$row_last = my_fetch_array($last_struktur_result);
	$last_id = $row['struktur_gaji_id'];
	
	$query = "SELECT * FROM pr_struktur_gaji_tahun";
	$result = my_query($query);
	$struktur_opsi = array();
	while($row_struktur = my_fetch_array($result)){
		$struktur_opsi[$row_struktur['struktur_gaji_id']] = $row_struktur['nomor_sk'];  
	}
	
	$struktur_gaji = array(
		'name'=>'struktur_gaji_id',
		'value'=>$last_id,
		'id'=>'file' ,'size'=>'70',
		'type'=>'file'
	);
	
	$form_struktur_gaji = form_dropdown($struktur_gaji , $struktur_opsi );
	$view .= form_field_display( $form_struktur_gaji , "Strtuktur gaji by grade" );
	*/
	$file = array(
			'name'=>'filexl',
			'value'=>(isset($_POST['filexl'])? $_POST['filexl'] : $fields['filexl']),
			'id'=>'file' ,'size'=>'70',
			'type'=>'file'
	);
	$form_nominal = form_dynamic($file);
	$view .= form_field_display( $form_nominal , "Final Skor CSV" );
	
	$submit = array(
		'value' => ' Proses ',
		'name' => 'simpan', 
		'type'=>'submit','class'=>'main_button'
	);
	$form_submit= form_dynamic($submit); 
	
	$view .= form_field_display( $form_submit  , "&nbsp;" ,  "" );
	$view .= form_footer( );
	return $view;
}

function auto_penilaian($karyawan_id , $skor , $penilaian_id){
		$total_nilai=$count_nilai=0;  
		$query_penilain = "SELECT * FROM unsur_evaluasi WHERE penilaian_id = {$penilaian_id}";
		$result_penilaian = my_query($query_penilain);
		while($rp  = my_fetch_array($result_penilaian)){	
			$unsur_id = $rp['unsur_evaluasi_id'];
			$query = "SELECT evaluasi_id FROM evaluasi WHERE unsur_evaluasi_id = {$unsur_id}";
			$result = my_query($query);
			while($row = my_fetch_array($result)){
				if($skor =='A'){	
					$mix = rand(86,100);
				}elseif($skor =='B'){
					$mix = rand(73,85);
				}elseif($skor =='C'){
					$mix = rand(56,72);
				}elseif($skor =='D'){
					$mix = rand(45,56);
				}else{
					$mix = rand(10,44);
				}
				my_query("DELETE FROM penilaian_karyawan_evaluasi WHERE evaluasi_id ={$row['evaluasi_id']} AND karyawan_id = {$karyawan_id}");
				$datas = array(
					'karyawan_id'	=>my_type_data_int($karyawan_id),
					'evaluasi_id'	=>my_type_data_int($row['evaluasi_id']),
					'nilai'			=>my_type_data_str($mix),
				);
				my_insert_record( 'penilaian_karyawan_evaluasi' , $datas ); 
			}
		}
		
		if($skor =='A'){	
			$evaluasi_nilai_id = 5; 
		}elseif($skor =='B'){
			$evaluasi_nilai_id = 4; 
		}elseif($skor =='C'){
			$evaluasi_nilai_id = 3; 
		}elseif($skor =='D'){
			$evaluasi_nilai_id = 2; 
		}else{
			$evaluasi_nilai_id = 1; 
		}
		my_query("DELETE FROM penilaian_karyawan WHERE karyawan_id={$karyawan_id} AND penilaian_id={$penilaian_id} ");
		$datas2 = array(
			'karyawan_id' 		=> my_type_data_int($karyawan_id) ,
			'penilaian_id'		=> my_type_data_int($penilaian_id), 
			'evaluasi_nilai_id' => my_type_data_int($evaluasi_nilai_id) 
		);
		my_insert_record('penilaian_karyawan',$datas2  );
		
}


function stor_data_kenaikan_pa($data,$penilaian_id){

	ini_set("max_execution_time","10000");
	$nik = $data[0];
	$skor = $data[1];
	$struktur_gaji_id = $_POST['struktur_gaji_id'];
	
	$query = "SELECT b.karyawan_id , b.gapok_km, b.grade_id ,b.status_id FROM karyawan a 
	INNER JOIN kekaryawanan b ON a.karyawan_id = b.karyawan_id
	WHERE a.nik ='{$nik}' ORDER BY b.karyawan_id DESC LIMIT 1";
	$res = my_query($query);
	$row = my_fetch_array($res);
	$karyawan_id = $row['karyawan_id'];		//DATA ID KARYAWAN YBS
	$grade_id = $row['grade_id'];		//DATA GRADE KARYAWAN YBS
	
	 auto_penilaian($karyawan_id , $skor  , $_GET['penilaian_id']);
}	
function upload_kenaikan_pa_csv($penilaian_id){
	$path 		= 'files/kenaikan/';
	$filename 	= strtolower($_FILES['filexl']['name']);
	$upload 	= move_uploaded_file($_FILES['filexl']['tmp_name'] , $path.$filename);
	
	if($upload){
		$t = 0;
		$handle = fopen($path.$filename, "r");
		while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { 
			stor_data_kenaikan_pa($data,$penilaian_id); 
		} 
		fclose($handle);
	}
	return true;
}

function list_evaluasi($penilaian_id, $karyawan_id){

	my_set_code_js(' 
		function submitUpdateNilai( evaluasi_id,  value){
			if( isNaN(value) ){
				alert(\'Data bukan angka\');
				$(\'#fskor_\'+evaluasi_id).val(0);
				return false;
			}
			
			else if(value < 0){
				alert(\'Data tidak bisa kurang dari 0\');
				$(\'#fskor_\'+evaluasi_id).val(0);
				return false;
			}
			
			else if(value > 100){
				alert(\'Data tidak bisa lebih dari 100\');
				$(\'#fskor_\'+evaluasi_id).val(0);
				return false; 
			}
			else{
			return true;
			}
		}

		function outOfValue(x){
			
		}
	');

	$karyawans= loaddata_karyawan($karyawan_id);
 
 	$header  = array(
		'#'=>array('style'=>'border-bottom:2px solid;width:5%'), 
		'Evaluasi'=>array('style'=>'border-bottom:2px solid;width:30%'),  
		'Uraian Hasil Kerja'=>array('style'=>'border-bottom:2px solid;width:55%'),  
		'Nilai'=>array('style'=>'text-align:center;border-bottom:2px solid;width:10%'),   
	);
	$status=( isset($karyawans['kelompok_evaluasi']) ? $karyawans['kelompok_evaluasi'] : 'Pelaksana' ) ;
	$query = "SELECT * FROM evaluasi  a
			INNER JOIN unsur_evaluasi b ON a.unsur_evaluasi_id = b.unsur_evaluasi_id 
			WHERE b.penilaian_id={$penilaian_id} 
			AND b.".$status."='Y' 
			ORDER BY a.unsur_evaluasi_id,a.evaluasi_id ";
	 
	$result = my_query($query);
	$i = 0;
	$total_nilai=0;
	$unsur_evaluasi_id=0;
	$row = array();
	while($r = my_fetch_array($result) ){
		$i++;
		if($unsur_evaluasi_id<>$r['unsur_evaluasi_id']){
			$unsur_evaluasi_id=$r['unsur_evaluasi_id'];
			$row[] = array(
				'#'=> ' ',      
				'evaluasi'=>'<b>'.strtoupper(  $r['nama_unsur_evaluasi']).'</b>',
				'uraian'=> ' ',
				'nilai'=>' ' ,  
			); 		
		}

		$skor = get_skor_value($karyawan_id , $r['evaluasi_id']);		
		$fskor = array(
			'name'=>'fskor['.$r['evaluasi_id'].']',
			'id'=>'fskor_'.$r['evaluasi_id'],
			'value'=>(int)$skor,
			'size'=>'3',
			//'onchange'=>'javascript:submitUpdateNilai( '.$r['evaluasi_id'].', this.value)' 
		);
		$skor_form = form_dynamic($fskor);
		$row[] = array(
			'#'=> $i,      
			'evaluasi'=>  $r['nama_evaluasi'],
			'uraian'=> $r['uraian'],
			'nilai'=>position_text_align( $skor_form   ,'center') ,  
		); 
		$total_nilai+=$skor;
	}
	$rata_rata=ROUND($total_nilai/$i,0);
	$nilais=get_evaluasi_nilai($rata_rata);	
	$row[] = array(
		'#'=> ' ',      
		'evaluasi'=> 'RATA-RATA NILAI : '.$rata_rata.' / '.$nilais['huruf'].' / '.$nilais['keterangan'],
		'uraian'=> position_text_align(  'T O T A L'  ,'right')	 ,
		'nilai'=>position_text_align($total_nilai,'right')	 ,
	); 	
	$datas = table_rows($row);
	$pro = karyawan_header_detail($karyawans, true  );
	$menuontop = array(  
		'Cetak' => array('onclick'=>'javascript:window.open(\'index.php?com=report&task=penilaian&penilaian_id='.$penilaian_id.'&karyawan_id='.$karyawan_id.'\',\'mywin\',\'left=20,top=20,width=800,height=600,toolbar=0,resizable=0\');'),
		'Back' => array('onclick'=>'javascript:location.href=\'index.php?com=penilaian&task=list_karyawan&penilaian_id='.$penilaian_id.'\''),
		'Post' => array('onclick'=>'javascript:document.ssbn.submit()')
	);
	$printmenu = additional_menu_on_list( $menuontop , '');
	return $pro.$printmenu. '<form method="POST" name="ssbn">'.table_builder($header , $datas ,  5 , false ).'</form>';
}
	

function get_skor_value($karyawan_id , $evaluasi_id){
	$evaluasi_id=( isset($evaluasi_id) ? $evaluasi_id : 0 ) ;
	$query = "SELECT nilai FROM penilaian_karyawan_evaluasi 
		WHERE karyawan_id ={$karyawan_id} AND
		evaluasi_id ={$evaluasi_id}
	"; 
	$result = my_query($query);
	if(my_num_rows($result) > 0){
		$row = my_fetch_array($result);
		return $row['nilai']; 
	}return false;
}

function get_evaluasi_nilai($angka){
	$nilai=$angka+1;
	$query = "SELECT * FROM evaluasi_nilai 
		WHERE angka<".$nilai." ORDER BY angka desc LIMIT 1
	"; 
	$result = my_query($query);
	if(my_num_rows($result) > 0){
		$row = my_fetch_array($result);
		return $row; 
	}
	return false;
}

function update_evaluasi($penilaian_id,$karyawan_id,$total_nilai,$count_nilai){

	if( $total_nilai==0){
		$rata_rata=0 ;
	}else{
		$rata_rata=round($total_nilai/$count_nilai,0);
	}
	$nilais=get_evaluasi_nilai($rata_rata);	
	$evaluasi_nilai_id=$nilais['evaluasi_nilai_id'] ;

	$query = "SELECT karyawan_id FROM penilaian_karyawan 
		WHERE karyawan_id ={$karyawan_id} 
		AND penilaian_id ={$penilaian_id} 
	"; 
	$result = my_query($query);
	if(my_num_rows($result) > 0){
		$query = "UPDATE penilaian_karyawan 
			SET evaluasi_nilai_id ={$evaluasi_nilai_id}  
			WHERE karyawan_id ={$karyawan_id} 
			AND penilaian_id ={$penilaian_id} 
		";  
	}else{
		$query = "INSERT penilaian_karyawan 
				SET karyawan_id ={$karyawan_id} ,
				penilaian_id ={$penilaian_id}, 
				evaluasi_nilai_id ={$evaluasi_nilai_id}  
			";  
	}
	$result = my_query($query);
	return $result;
}


function print_plain($penilaian_id){
	$nik_start = isset( $_GET['nik_start'] ) ? sprintf('%07d',(int) $_GET['nik_start']) :  '0000001';
	$nik_end = isset( $_GET['nik_end'] ) ? sprintf('%07d',(int) $_GET['nik_end']) :  '9999999' ;		
	$query = "
		SELECT a.karyawan_id, c.evaluasi_nilai_id FROM karyawan a 
		INNER JOIN biodata b ON a.biodata_id = b.biodata_id
		LEFT JOIN penilaian_karyawan c ON c.karyawan_id = a.karyawan_id AND c.penilaian_id={$penilaian_id} 
		WHERE a.karyawan_id NOT IN (select karyawan_id FROM karyawan_disable)
		AND a.karyawan_id NOT IN (select karyawan_id FROM pemberhentian)";  
	 if($_GET['nik_start'] <> '' && $_GET['nik_end'] <> ''){
		$query .=" AND ( a.nik BETWEEN {$_GET['nik_start']} AND {$_GET['nik_end']} ) ";
	}			
	$query .=" ORDER BY a.nik ";
	$result = my_query($query ); 
	$datas = array();  
	$i=1;
	
	$datas[] = array(
		 'k1'=>array("NO" ,5 ,STR_PAD_BOTH),
		 'k2'=>array("NIK" ,10,STR_PAD_RIGHT),
		 'k3'=>array("Nama" ,30,STR_PAD_RIGHT),
		 'k4'=>array("Jabatan" ,45,STR_PAD_RIGHT),  
		 'k5'=>array("Nilai" ,10,STR_PAD_BOTH),  
	); 
	$datas[] = array(	//FOR HEADER SPACE (NECK)
		 'k1'=>array(" " ,5 ,STR_PAD_BOTH),
		 'k2'=>array(" " ,10,STR_PAD_RIGHT),
		 'k3'=>array(" " ,30,STR_PAD_RIGHT),
		 'k4'=>array(" " ,45,STR_PAD_RIGHT),  
		 'k5'=>array(" " ,10,STR_PAD_LEFT),  
	); 
	$i=0;
	while($ey = my_fetch_array($result)){

		$karyawan = loaddata_karyawan($ey['karyawan_id']);  
		$jabatans = my_get_data_by_id('jabatan','jabatan_id',( isset($karyawan['jabatan_id']) ? $karyawan['jabatan_id'] : 0 ));
		$evaluasi_nilai_id=(isset($ey['evaluasi_nilai_id']) ? $ey['evaluasi_nilai_id'] :0 );
		$evaluasi_nilais = my_get_data_by_id('evaluasi_nilai','evaluasi_nilai_id',$evaluasi_nilai_id );		
		$i++; 
		
		$datas[] = array(		 
			'k1'=>array($i ,5 ,STR_PAD_BOTH),
			'k2'=>array($karyawan['nik'],10,STR_PAD_RIGHT),
			'k3'=>array($karyawan['nama_gelar'] ,30,STR_PAD_RIGHT),
			'k4'=>array($jabatans['nama_jabatan'],45,STR_PAD_RIGHT),  
			'k5'=>array($evaluasi_nilais['keterangan'] ,10,STR_PAD_BOTH),  
		);
	}
	$view = 	str_pad("CETAK PENILAIAN",100," ",STR_PAD_BOTH);
	return $view ."\n"."\n".set_txt_report($datas);
}

function excel_report($penilaian_id){
	my_component_load('xl_builder' , false);
	$header = array(
		'#'=>array('style'=>'text-align:center;border-bottom:2px solid;width:5%'), 
		'nik'=>array('style'=>'text-align:center;border-bottom:2px solid;width:10%'),   
		'nama'=>array('style'=>'border-bottom:2px solid;width:30%'),  
		'jabatan'=>array('style'=>'border-bottom:2px solid;width:45%'), 
		'nilai'=>array('style'=>'border-bottom:2px solid;width:10%'), 		
	);

	$nik_start = isset( $_GET['nik_start'] ) ? sprintf('%07d',(int) $_GET['nik_start']) :  '0000001';
	$nik_end = isset( $_GET['nik_end'] ) ? sprintf('%07d',(int) $_GET['nik_end']) :  '9999999' ;		
	$query = "
		SELECT a.karyawan_id, c.evaluasi_nilai_id FROM karyawan a 
		INNER JOIN biodata b ON a.biodata_id = b.biodata_id
		LEFT JOIN penilaian_karyawan c ON c.karyawan_id = a.karyawan_id AND c.penilaian_id={$penilaian_id} 
		WHERE a.karyawan_id NOT IN (select karyawan_id FROM karyawan_disable)
		AND a.karyawan_id NOT IN (select karyawan_id FROM pemberhentian)";  
	 if($_GET['nik_start'] <> '' && $_GET['nik_end'] <> ''){
		$query .=" AND ( a.nik BETWEEN {$_GET['nik_start']} AND {$_GET['nik_end']} ) ";
	}			
	$query .=" ORDER BY a.nik ";
	$result = my_query($query ); 
	$row = array();  
	$i=1;
	while($ey = my_fetch_array($result)){
		$karyawan = loaddata_karyawan($ey['karyawan_id']);  
		$jabatans = my_get_data_by_id('jabatan','jabatan_id',( isset($karyawan['jabatan_id']) ? $karyawan['jabatan_id'] : 0 ));
		$evaluasi_nilai_id=(isset($ey['evaluasi_nilai_id']) ? $ey['evaluasi_nilai_id'] :0 );
		$evaluasi_nilais = my_get_data_by_id('evaluasi_nilai','evaluasi_nilai_id',$evaluasi_nilai_id );		
		$row[] = array(
			'#'=> $i, 
			'nik'=> '\''. $karyawan['nik'], 
			'nama'=>$karyawan['nama_gelar'],  
			'jabatan'=> $jabatans['nama_jabatan'],  
			'nipar'=>$evaluasi_nilais['keterangan'],  
		);
		 $i++;
	}
	
	$datas = table_rows_excel($row); 
	return table_builder_excel($header , $datas , 15 ,false ); 
}